<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Gallery extends MY_Controller {

    public function index() {
        
        $data['logged_in']  = $this->logged_in;
        $data['is_admin']   = $this->is_admin;
        $data['first_name'] = $this->first_name;

        $data['title'] = "Central Alabama VW Club -- Gallery";
        $data['heading'] = "Gallery";
		
		$data['member_list'] = $this->_get_members();


        $data['view'] = 'gallery_view';
        $this->load->vars($data);
        $this->load->view('master_view', $data);
        
        return;
    }
	
    function _get_members(){
        
       $this->load->model('Member_model');
		$member_list_array = $this->Member_model->Get_member_list();
        
        $gallery_html   =   '';
        $gallery_html   .=  '<table class="member-gallery-grid">';
		       
		//loop through the results and checkbox the id
        $row_pic_count  =   0;
        $image_row      =   '';
        $action_row     =   '';
        $start_count    =   false;
		foreach($member_list_array as $row) {
           if ($start_count)
            $row_pic_count++;
           else
            $start_count =   true;
           
           if ($row_pic_count == MAX_ROW_PICS) {
               $gallery_html .= '<tr>'.$image_row.'</tr><tr>'.$action_row.'</tr>';
               $action_row = '';
               $image_row = '';
               $row_pic_count = 0;
           }
               
           $thumb_link  = '<img src="./profile_photos/thumbnail/'.$row['profile_pic'].'"/>';
           $image_row   .=   '<td class="image-cell">'.$thumb_link.'</td>';
           $action_row  .= '<td class="action-row"> <a href="'.base_url().'index.php?/member_profile/index/'.$row['member_id'].'">'.$row['display_name'].'</a></td>';
		}
		$gallery_html .= '<tr>'.$image_row.'</tr><tr>'.$action_row.'</tr>';
        $gallery_html .= '</table>';
		
		
		return $gallery_html;
    }


}

/* End of file links.php */
/* Location: ./application/controllers/links.php */